
//
//  YHKTabBarController.m
//  微博oc
//
//  Created by 杨和逵 on 16/2/27.
//  Copyright © 2016年 yanghekui. All rights reserved.
//

#import "YHKTabBarController.h"
#import "YHKNavController.h"
#import "YHKHomeViewController.h"
#import "YHKFindViewController.h"
#import "YHKMessageViewController.h"
#import "YHKSettingViewController.h"
#import "YHKTabBar.h"
@interface YHKTabBarController ()

@end

@implementation YHKTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //设置自定义的tabBar
    YHKTabBar *myTabBar = [[YHKTabBar alloc]init];
    
    //通过kvc去设置只读属性
    [self setValue:myTabBar forKey:@"tabBar"];
    
    
    
    
    
    
    //初始化控制器
    YHKHomeViewController *homeVC = [[YHKHomeViewController alloc]init];
    [self addChildVC:homeVC :@"首页" :@"tabbar_home"];
    
    YHKFindViewController *findVC = [[YHKFindViewController alloc]init];
    [self addChildVC:findVC :@"消息" :@"tabbar_message_center"];
    YHKMessageViewController *messageVC = [[YHKMessageViewController alloc]init];
    [self addChildVC:messageVC :@"发现" :@"tabbar_discover"];
    YHKSettingViewController *settingVC = [[YHKSettingViewController alloc]init];
    [self addChildVC:settingVC :@"设置" :@"tabbar_profile"];
//    [self [UITabBar appearance]tintColor].orangeColor;

    
    
    
}

- (void)addChildVC:(UIViewController *)VC :(NSString *)titie :(NSString *)image  {
    

    
    YHKNavController *nav = [[YHKNavController alloc]initWithRootViewController:VC];
    
    VC.navigationItem.title = titie;//设置nav的titel
    
    VC.tabBarItem.title = titie;
    VC.tabBarItem.image = [UIImage imageNamed:image];
    VC.tabBarItem.selectedImage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_highlighted",image]];

    //颜色
    //初始化一个文字属性字典
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    //添加颜色属性
    dict[NSForegroundColorAttributeName] = [UIColor orangeColor];
    //把文字属性字典添加到TextAttributes
    [VC.tabBarItem setTitleTextAttributes:dict forState:UIControlStateSelected];
    
    
    //添加控制器
    [self addChildViewController: nav];
    
    
}


@end
